﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExaminationTT.Model;

namespace ExaminationTT.Utils
{
    public class Utilities
    {
        public static bool ExamIntersects(IExam exam1, IExam exam2)
        {
            if (exam1 == exam2) return false;
            return exam1.ExamDate >= exam2.ExamDate && exam1.ExamDate <= exam2.ExamDate // data de inicio do exam1 intersecta o exam2
                || exam1.ExamEndDate >= exam2.ExamDate && exam1.ExamEndDate <= exam2.ExamDate // data de fim do exam1 intersecta o exam2
                || exam1.ExamDate <= exam2.ExamDate && exam1.ExamEndDate >= exam2.ExamEndDate //exam 1 sobrepoe exam 2
                || exam2.ExamDate <= exam1.ExamDate && exam2.ExamEndDate >= exam1.ExamEndDate;
        }
    }
}
